How to Add a Domain to GitLab

This guide will show you how to set up a custom domain for your GitLab instance. Before this, you should:

  • have a valid domain name and you have permission to update DNS for your domain;
  • have SSL certificate for your domain;

1 Upload your SSL certificate

First, create a new folder named "SSL" under /var/opt/gitlab/ by using the command mkdir /var/opt/gitlab/SSL in the SSH.

Then, create two new files tls.crt and tls.key under /var/opt/gitlab/SSL/. After that, copy your crt into tls.crt and copy your key into tls.key via the command below.

# vim /var/opt/gitlab/SSL/tls.crt
# vim /var/opt/gitlab/SSL/tls.key

2 Modify gitlab.rb

Gitlab.rb is located at /var/opt/gitlab/config/, modify the content at the bottom of gitlab.rb file.

Change the content in the "Configure SSL and Domain" section to below:

nginx['enable'] = true
nginx['client_max_body_size'] = '250m'
nginx['redirect_http_to_https'] = true
nginx['redirect_http_to_https_port'] = 80
nginx['ssl_certificate'] = "/var/opt/gitlab/SSL/tls.crt"
nginx['ssl_certificate_key'] = "/var/opt/gitlab/SSL/tls.key"
external_url 'https://{your-domain-name.com}'

3 Reconfigure gitlab

In the Shell/SSH, execute command below to reconfigure gitlab:

# gitlab-ctl reconfigure

4 Update DNS records for your domain

Update the DNS records for your domain and let your domain pointing to the IP address we provided in the client panel. You can find the IP information at the connection information section on the Overview page.

5 Check whether GitLab is accessible

Enter your domain name in browser, please do not forget to enter the port:

https://{your-domain-name.com}:{port}/

Copyright © 2022 Cloud Clusters Inc. all right reserved,powered by GitbookRevised on 05/31/2022

results matching ""

    No results matching ""